package com.bw.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bw.bean.DateBean;
import com.bw.servlect.DateServlect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 徐金浩
 * @date 2025年10月09日 18:24
 */
@RestController
public class DATEBEANController {
    @Autowired
   private DateServlect servlect;


    @RequestMapping("/s1")
    public JSONObject select1()
    {
        JSONObject result = new JSONObject();
        result.put("status",0);
        result.put("mag","");

        JSONObject data = new JSONObject();
        result.put("data",data);

        JSONArray columns = new JSONArray();
        JSONArray roes = new JSONArray();
        data.put("columns",columns);
        data.put("rows",roes);


        JSONObject c1 = new JSONObject();
        c1.put("id","name");
        c1.put("name","店铺名称");
        JSONObject c2 = new JSONObject();
        c2.put("id","cta");
        c2.put("name","金额");
        JSONObject c3 = new JSONObject();
        c3.put("id","ctb");
        c3.put("name","次数");
        JSONObject c4 = new JSONObject();
        c4.put("id","ctc");
        c4.put("name","人数");
        JSONObject c5 = new JSONObject();
        c5.put("id","ctd");
        c5.put("name","实收金额");
        JSONObject c6 = new JSONObject();
        c6.put("id","cte");
        c6.put("name","退款金额");

        columns.add(c1);
        columns.add(c2);
        columns.add(c3);
        columns.add(c4);
        columns.add(c5);
        columns.add(c6);

        List<DateBean> beans = servlect.selecte();
        for (DateBean bean : beans) {
            JSONObject row = new JSONObject();
            row.put("name",bean.getName());
            row.put("cta",bean.getCta());
            row.put("ctb",bean.getCtb());
            row.put("ctc",bean.getCtc());
            row.put("ctd",bean.getCtd());
            row.put("cte",bean.getCte());

            roes.add(row);
        }

        return result;
    }

    @RequestMapping("/s2")
    public JSONObject select2()
    {
        JSONObject result = new JSONObject();
        result.put("status",0);
        result.put("msg","");

        JSONObject data = new JSONObject();
        result.put("data",data);

        JSONArray columns = new JSONArray();
        data.put("columns",columns);
        JSONArray rows = new JSONArray();
        data.put("rows",rows);

        JSONObject c1 = new JSONObject();
        c1.put("id","name");
        c1.put("name","天数");
        JSONObject c2 = new JSONObject();
        c2.put("id","cta");
        c2.put("name","直营");
        JSONObject c3 = new JSONObject();
        c3.put("id","ctb");
        c3.put("name","加盟");

        columns.add(c1);
        columns.add(c2);
        columns.add(c3);

        List<DateBean> beans = servlect.selecte1();
        for (DateBean bean : beans) {
            JSONObject row = new JSONObject();
            row.put("name",bean.getName());
            row.put("cta",bean.getCta());
            row.put("ctb",bean.getCtb());

            rows.add(row);
        }


        return result;
    }

    @RequestMapping("/s3")
    public JSONObject select3()
    {
        JSONObject result = new JSONObject();
        result.put("status",0);
        result.put("msg","");

        JSONObject data = new JSONObject();
        result.put("data",data);

        JSONArray categories = new JSONArray();
        JSONArray series = new JSONArray();
        data.put("categories",categories);
        data.put("series",series);

        JSONObject se1 = new JSONObject();
        series.add(se1);
        se1.put("name","评价次数");
        JSONArray ser1_data = new JSONArray();
        se1.put("data",ser1_data);

        JSONObject se2= new JSONObject();
        series.add(se2);
        se2.put("name","好评次数");
        JSONArray ser2_data = new JSONArray();
        se2.put("data",ser2_data);

        JSONObject se3= new JSONObject();
        series.add(se3);
        se3.put("name","平均分");
        JSONArray ser3_data = new JSONArray();
        se3.put("data",ser3_data);

        JSONObject se4= new JSONObject();
        series.add(se4);
        se4.put("name","好评率");
        JSONArray ser4_data = new JSONArray();
        se4.put("data",ser4_data);




        List<DateBean> beans = servlect.selecte2();
        for (DateBean bean : beans) {
            categories.add(bean.getName());
            ser1_data.add(bean.getCta());
            ser2_data.add(bean.getCtb());
            ser3_data.add(bean.getCtc());
            ser4_data.add(bean.getCtd());
        }


        return result;
    }

    @RequestMapping("/s4")
    public JSONObject select4()
    {
        JSONObject result = new JSONObject();
        result.put("status",0);
        result.put("msg","");

        DateBean dateBean=servlect.select3();
        result.put("data",dateBean.getCta());

        return result;
    }

    @RequestMapping("/s5")
    public JSONObject select5()
    {
        JSONObject result = new JSONObject();
        result.put("status",0);
        result.put("msg","");

        JSONObject data = new JSONObject();
        result.put("data",data);

        JSONArray mapData = new JSONArray();
        data.put("mapData",mapData);


        List<DateBean> beans = servlect.selecte4();
        for (DateBean bean : beans) {
            JSONObject row = new JSONObject();

            row.put("name",bean.getName());
            row.put("value",bean.getCta());


            JSONArray tool = new JSONArray();
            row.put("tooltipValues",tool);
            tool.add(bean.getCtb());
            tool.add(bean.getCtc());

            mapData.add(row);
        }

        JSONArray tooltipNames = new JSONArray();
        data.put("tooltipNames",tooltipNames);
        tooltipNames.add("下单人数");
        tooltipNames.add("下单次数");

        JSONArray tooltipUnits = new JSONArray();
        data.put("tooltipUnits",tooltipUnits);
        tooltipUnits.add("平方公里");
        tooltipUnits.add("人");



        return  result;
    }


    @RequestMapping("/s6")
    public JSONObject selects2()
    {
        JSONObject result = new JSONObject();
        result.put("status",0);
        result.put("msg","");

        JSONArray data = new JSONArray();
        result.put("data",data);

        List<DateBean> beans = servlect.selecte2();
        for (DateBean bean : beans) {
            JSONObject row = new JSONObject();
            row.put("name",bean.getName());
            row.put("value",bean.getCtd());

            data.add(row);
        }




        return result;
    }

    @RequestMapping("/s7")
    public JSONObject select7()
    {
        JSONObject result = new JSONObject();
        result.put("status",0);
        result.put("msg","");

        JSONObject data = new JSONObject();
        result.put("data",data);

        JSONArray categories = new JSONArray();
        JSONArray series = new JSONArray();
        data.put("categories",categories);
        data.put("series",series);

        JSONObject se1 = new JSONObject();
        series.add(se1);
        se1.put("name","评价次数");
        JSONArray ser1_data = new JSONArray();
        se1.put("data",ser1_data);

        JSONObject se2= new JSONObject();
        series.add(se2);
        se2.put("name","好评次数");
        JSONArray ser2_data = new JSONArray();
        se2.put("data",ser2_data);

        JSONObject se3= new JSONObject();
        series.add(se3);
        se3.put("name","平均分");
        JSONArray ser3_data = new JSONArray();
        se3.put("data",ser3_data);

        JSONObject se4= new JSONObject();
        series.add(se4);
        se4.put("name","好评率");
        JSONArray ser4_data = new JSONArray();
        se4.put("data",ser4_data);




        List<DateBean> beans = servlect.selecte2();
        for (DateBean bean : beans) {
            categories.add(bean.getName());
            ser1_data.add(bean.getCta());
            ser2_data.add(bean.getCtb());
            ser3_data.add(bean.getCtc());
            ser4_data.add(bean.getCtd());
        }


        return result;
    }
}
